package com.ovopark.organize.server.common.constant;

import com.ovopark.organize.server.model.entity.MediaServerConfig;
import com.ovopark.organize.server.model.entity.SysParams;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ConstanComment {
    //订单总额异常
    public static final int AMOUNT_WARNING=1;
    //订单单品异常
    public static final int ORDER_WARNING=2;
    //消费次数异常
    public static final int COUNT_WARNING=3;
    //退单异常
    public static final int RETURN_WARNING=4;
    //折扣异常
    public static final int DISCOUNT_WARNING=5;
    //有单无人
    public static final int HAVE_ORDER_NO_PERSON=6;

    public static Map<String, String> map = new HashMap<String, String>();

    public static Map<String, String> systemProperty = new HashMap<String, String>();

    private static ExecutorService executor = Executors.newFixedThreadPool(1000);

    public static String template = "";
    //pc4客流设备
    public static final int PC4_DEVICE_TYPE = 0;
    //wifi探针设备
    public static final int WIFI_DEVICE_TYPE = 1;
    //人脸客流设备
    public static final int FACE_DEVICE_TYPE = 2;
    //人脸去重设备
    public static final int FACE_DEWEIGHT_DEVICE_TYPE = 3;

    //区域
    public static final int AREA_PORT = 1;
    //业态
    public static final int COMMERICAL_PORT = 2;
    //品牌
    public static final int BRAND_PORT = 3;
    //出入口
    public static final int PORT = 4;
    //试衣间
    public static final int FITTING_PORT = 5;
    //店外客流
    public static final int OUT_PASSENGER_PORT = 6;//圈外客流挂店外客流下
    //主出入口(is_primary_port =1 && tag_type = 0)
    public static final int PRIMARY_PORT = 7 ;

    public static final int OPERATION_ADD = 1;
    public static final int OPERATION_REMOVE = 2;
    public static final int OPERATION_MODIFY = 3;

    public static final int OFFLINE_ALERT = 1;
    public static final int ONLINE_ALERT = 2;
    public static final int MOVING_ALERT = 3;
    public static final int CHANNEL_ALERT = 4;
    public static final int VACANCY_ALERT = 5;
    public static final int VIDEO_ALERT=6;

    public static final int DM_ALARM_TYPE_IPC_OFFLINE = 0;  /* 前端掉线告警 */
    public static final int DM_ALARM_TYPE_NO_DISK	= 1;/* 没有磁盘 */
    public static final int DM_ALARM_TYPE_DISK_ERROR = 2;	    /* 磁盘错 */
    public static final int DM_ALARM_TYPE_IP_CONFLICT = 3;    /* IP冲突 */
    public static final int DM_ALARM_TYPE_RETICLE_BREAK = 4;    /* 网线断 */
    public static final int DM_ALARM_TYPE_NET_DROP = 5; /* 网速下降 */
    public static final int DM_ALARM_TYPE_RECROOM_FULL= 6;    /* 录像空间满 */
    public static final int DM_ALARM_TYPE_GRPROOM_FULL= 7;    /* 抓拍空间满 */
    public static final int DM_ALARM_TYPE_MEM_LACK= 8;    /* 内存不足 */
    public static final int DM_ALARM_TYPE_CPU_OVERLOAD= 9;   /* cpu过载 */
    public static final int DM_ALARM_TYPE_MAC_CONFLICT  = 10;  /* MAC地址冲突 */
    public static final int DM_ALARM_TYPE_REC_ERROR = 11;  /* 录像失败 */
    public static final int DM_ALARM_TYPE_REC_CLOSE = 12;  /* 录像关闭 */
    public static final int DM_ALARM_TYPE_REC_LOST = 13;   /* 视频源丢失 */

    /**
     * 入侵检测
     */
    public static final int INTRUSION_ALERT = 8;

    public static final int UPGRADE_SUCCESS_NOTIFY = 6;
    public static final int UPGRADE_FAILED_NOTIFY = 7;
    public static final int RANDOM_CHECK_COUNT = 5;
    // 置顶
    public static final int DIRECTION_TOP = 0;
    // 上移
    public static final int DIRECTION_UP = 1;
    // 下移
    public static final int DIRECTION_DOWN = 2;
    // 置底
    public static final int DIRECTION_BOTTOM = 3;

    public static final String COMMON_ON = "ON";//开
    public static final String COMMON_OFF = "OFF";//关
    private static SysParams sysParam = new SysParams();
    private static MediaServerConfig defaultMediaServerConfig;
    private static Map<Integer, MediaServerConfig> mediaServerConfigMap = new ConcurrentHashMap<>();
    //oss路径
    public static final String OSS_URL = "http://oss-cn-hangzhou.aliyuncs.com/ovopark/";


    // 默认语言：简体中文
    public static final String DEFAULT_LANG = "SIMPLIFIED_CHINESE";
    // 默认时区：东八区
    public static final String DEFAULT_TIME_ZONE = "GMT+8:00";

    public static final String OOS_PREFIX = "OOS_";
    public static final String OOS_CAPTURE_PREFIX = "OOSCAP_";
    public static final String FR3_CAPTURE_PREFIX = "FR3CAP_";
    public static final String DEV_MANAGER_CAP_PREFIX = "DEVMANAGERCAP_";
    public static final String ONLY_THUMB_ = "ONLYTHUMB_";

    public static final int CUSTOMER_TAG_CATEGORY = 0;//客流设备

    //public static final int FACE_TAG_CATEGORY = 4;//人脸客流设备

    /**
     * 导出excel 限制条数
     */
    public static final int EXPORT_MAX_NUMBER=4000;

    /**
     * 录像下载队列 key
     */
    public static final String DELAY_MESSAGE_KEY = "delay_message_key_";
    /**
     * 录像下载nvr key
     */
    public static final String DELAY_MESSAGE_DEVICE_KEY = "delay_message_device_key_";

    //用户状态
    public static final String active="0"; //正常
    public static final String frozen="1"; //已冻结

    static {

        ResourceBundle rb = ResourceBundle.getBundle("i18n/platform");
        Enumeration<String> keys = rb.getKeys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            map.put(key, rb.getString(key));
        }

        ResourceBundle sytems = ResourceBundle.getBundle("i18n/system");
        Enumeration<String> sytemKeys = sytems.getKeys();
        while (sytemKeys.hasMoreElements()) {
            String key = sytemKeys.nextElement();
            systemProperty.put(key, sytems.getString(key));
        }

        try {
            StringBuilder stringBuilder = new StringBuilder();
            File file = new File("/extend/shopweb/version/template/mail_template.txt");
            if (file.isFile() && file.exists()) {
                InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "utf-8");
                BufferedReader br = new BufferedReader(isr);
                String lineTxt = null;
                while ((lineTxt = br.readLine()) != null) {
                    stringBuilder.append(lineTxt);
                }
                br.close();
                template = stringBuilder.toString();
            } else {
                System.out.println("文件不存在!");
            }
        } catch (Exception e) {
            System.out.println("文件读取错误!");
        }
    }

    public static SysParams getSysParam() {
        return sysParam;
    }

    public static void setSysParam(SysParams sysParam) {
        ConstanComment.sysParam = sysParam;
    }

    public static MediaServerConfig getDefaultMediaServerConfig() {
        return defaultMediaServerConfig;
    }

    public static void setDefaultMediaServerConfig(MediaServerConfig defaultMediaServerConfig) {
        ConstanComment.defaultMediaServerConfig = defaultMediaServerConfig;
    }

    public static Map<Integer, MediaServerConfig> getMediaServerConfigMap() {
        return mediaServerConfigMap;
    }

    public void setMediaServerConfigMap(Map<Integer, MediaServerConfig> mediaServerConfigMap) {
        ConstanComment.mediaServerConfigMap = mediaServerConfigMap;
    }

    public static ExecutorService getThreadPool() {
        return executor;
    }

    //设置企业最大有效期（天）
    public static final Integer MAX_EXPIRE_INTERVAL=365;
    //设置企业默认有效期
    public static final Integer DEFAULT_EXPIRE_INTERVAL=3;

    public static final String staticFilePath="/extend/shopweb/";
    public static final String mediaServerPort= "5550";
    public static final String mediaAdapterPort= "5580";
    public static final String version= "20180705";
    public static final String  DEVICE_THUMB_PATH= "/extend/shopweb/snapshot/devimg/{0}_thumb";
    public static final String  DEVICE_THUMB_DIR= "/extend/shopweb/snapshot/devimg/";

    // 组织架构
    public static final int TYPE_ORGANIZE = 0;
    // 考评大项
    public static final int TYPE_PARENT_VIEWSHOP = 1;
    // 考评小项
    public static final int TYPE_DB_VIEWSHOP = 2;
    // 场景模板
    public static final int TYPE_SCENE = 3;
    // 掌上学院行业
    public static final int TYPE_TRAININGNav = 4;
    // 掌上学院标签
    public static final int TYPE_TRAININGLABEL = 5;
    // 点检项检查表
    public static final int TYPE_CHECKTEMPLATE_VIEWSHOP = 6;
    // 标签排序
    public static final int TYPE_ENTERPRISE_TAG = 7;
    // 分组排序
    public static final int TYPE_CHILD_ENTERPRISE_TAG = 8;



}
